package defpackage; import android.app.Activity; import android.app.LoaderManager; import android.content.Loader; import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import cn.wps.moffice.OfficeApp; import cn.wps.moffice.cntemplate.bean.TemplateCategory; import cn.wps.moffice.common.beans.DynamicLinearLayout; import cn.wps.moffice.main.local.filebrowser.search.common.FlowLayout; import cn.wps.moffice.main.local.home.newfiles.template.TemplateCategoryActivity; import cn.wps.moffice_eng.R; import com.google.gson.reflect.TypeToken; import defpackage.cup; import java.util.List; /* renamed from: gir reason: default package */ public final class gir extends ghk implements View.OnClickListener, DynamicLinearLayout.a { private FlowLayout gZS; private View gZT; private TemplateCategory hdA; private View hdB; private View hdC; private View hdD; private DynamicLinearLayout hdE; private TextView hdF; private FlowLayout hdt; private View hdu; private View hdv; private String[] hdw; private String[] hdx; private String[] hdy; private String[] hdz; public gir(gis gis, Activity activity) { super(gis, activity); } private void a(TemplateCategory.Category category) { try { int bOS = this.haW.bOS(); String str = category == null ? "more" : category.text; if (bOS == 0) { loe.D(this.mActivity, "searchpage", str); } else { TemplateCategoryActivity.a(this.mActivity, str, bOS, 3, "searchpage"); } } catch (Exception e) { } } static /* synthetic */ void a(gir gir, final int i) { gir.mActivity.getLoaderManager().initLoader(9, null, new LoaderManager.LoaderCallbacks<TemplateCategory>() { /* class defpackage.gir.AnonymousClass3 */ @Override // android.app.LoaderManager.LoaderCallbacks public final Loader<TemplateCategory> onCreateLoader(int i, Bundle bundle) { gnd bRL = gnd.bRL(); return new log(gir.this.mActivity.getApplicationContext()).HX("https://docer.wps.cn/v3.php/api/android/mb/v3/search_link").eT("X-Requested-With", "XMLHttpRequest").eU("mb_app", String.valueOf(i)).b(new TypeToken<TemplateCategory>() { /* class defpackage.gnd.AnonymousClass2 */ }.getType()); } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [android.content.Loader, java.lang.Object] */ @Override // android.app.LoaderManager.LoaderCallbacks public final /* synthetic */ void onLoadFinished(Loader<TemplateCategory> loader, TemplateCategory templateCategory) { gir.this.hdA = templateCategory; gir.g(gir.this); } @Override // android.app.LoaderManager.LoaderCallbacks public final void onLoaderReset(Loader<TemplateCategory> loader) { } }); } private void bPx() { int i = 0; int i2 = this.gZS.hbG; String[] strArr = new String[this.hdw.length]; int length = this.hdw.length; int i3 = 0; while (i3 < (length - 1) - i2) { strArr[i3] = this.hdw[i2 + 1 + i3]; i3++; } int i4 = length - i3; while (i < i4) { strArr[i3] = this.hdw[i]; i++; i3++; } this.hdw = strArr; refreshView(); } static /* synthetic */ void g(gir gir) { if (gir.hdA == null || gir.hdA.czv == null || gir.hdA.czv.size() <= 0) { gir.hdv.setVisibility(8); return; } gir.hdv.setVisibility(0); dwp.lV(gir.vY("searchpage_more_show")); gir.hdE.setAdapter(new giq(gir.hdE, gir.hdA.czv)); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private String vY(String str) { return gnb.yd(this.haW.bOS()) + "_" + str; } @Override // defpackage.ghk public final ViewGroup bOv() { this.haY = (ViewGroup) this.haX.findViewById(R.id.file_search_preview_content); LayoutInflater.from(this.mActivity).inflate(R.layout.phone_public_filebrowser_search_model_page, this.haY); this.gZT = this.haX.findViewById(R.id.phone_public_recommend_parent); this.hdu = this.haX.findViewById(R.id.phone_public_history_parent); this.hdv = this.haX.findViewById(R.id.phone_public_category_parent); this.gZS = (FlowLayout) this.haX.findViewById(R.id.phone_public_recommend_flowlayout); this.hdt = (FlowLayout) this.haX.findViewById(R.id.phone_public_history_flowlayout); this.hdE = (DynamicLinearLayout) this.haX.findViewById(R.id.phone_public_category_layout); this.hdF = (TextView) this.haX.findViewById(R.id.subject_text); this.hdB = this.haX.findViewById(R.id.phone_public_history_clean); this.hdC = this.haX.findViewById(R.id.phone_public_change_hotword); this.hdD = this.haX.findViewById(R.id.phone_public_category_more); this.hdB.setOnClickListener(this); this.hdC.setOnClickListener(this); this.hdD.setOnClickListener(this); this.hdE.setOnItemClickListener(this); return this.haY; } @Override // defpackage.ghk public final void bOw() { super.bOw(); if (this.haW instanceof gis) { gmz.V("searchpage_show", this.haW.bOS()); } new fcv<Void, Void, Void>() { /* class defpackage.gir.AnonymousClass2 */ /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object[]] */ /* access modifiers changed from: protected */ @Override // defpackage.fcv public final /* synthetic */ Void doInBackground(Void[] voidArr) { List<String> xH = ghe.xH(2); if (xH.size() > 0) { gir.this.hdz = new String[xH.size()]; for (int i = 0; i < xH.size(); i++) { gir.this.hdz[i] = xH.get(i); } } if (gir.this.hdy != null) { return null; } int bOS = gir.this.haW.bOS(); gir.this.hdy = gja.xP(bOS); return null; } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ /* access modifiers changed from: protected */ @Override // defpackage.fcv public final /* synthetic */ void onPostExecute(Void r3) { gir.this.hdx = gir.this.hdz; if (gir.this.hdw == null) { gir.this.hdw = gir.this.hdy; } gir.this.refreshView(); gir.a(gir.this, gir.this.haW.bOS()); } }.execute(new Void[0]); cup.a(this.mActivity, "android_template_search", this.haW.bOS(), hashCode(), new cup.k() { /* class defpackage.gir.AnonymousClass4 */ @Override // defpackage.cup.k public final void b(cto cto) { if (cto == null || cto.czc == null || cto.czc.czi == null || cto.czc.czi.czl == null || cto.czc.czi.czl.size() <= 0) { gir.this.hdF.setVisibility(8); return; } final String str = cto.czc.czi.czl.get(0).czn; final String str2 = cto.czc.czi.czl.get(0).czo; if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) { dwp.at(gir.this.vY("searchpage_hd_show"), str); gir.this.hdF.setVisibility(0); gir.this.hdF.setText(str); gir.this.hdF.setOnClickListener(new View.OnClickListener() { /* class defpackage.gir.AnonymousClass4.AnonymousClass1 */ public final void onClick(View view) { hdy.a(gir.this.mActivity, str2, "webview"); dwp.at(gir.this.vY("searchpage_hd_click"), str); } }); } } }); } public final void bxn() { if (this.haY != null && this.haY.getVisibility() == 0) { new Handler().postDelayed(new Runnable() { /* class defpackage.gir.AnonymousClass1 */ public final void run() { gir.this.refreshView(); } }, 200); } } @Override // cn.wps.moffice.common.beans.DynamicLinearLayout.a public final void d(View view, int i) { TemplateCategory.Category category = this.hdA.czv.get(i); if (category != null) { dwp.at(vY("searchpage_category_click"), category.text); a(category); } } public final void onClick(View view) { switch (view.getId()) { case R.id.phone_public_category_more /*{ENCODED_INT: 2131366194}*/: dwp.lV(vY("searchpage_more_click")); a((TemplateCategory.Category) null); return; case R.id.phone_public_change_hotword /*{ENCODED_INT: 2131366196}*/: bPx(); return; case R.id.phone_public_history_clean /*{ENCODED_INT: 2131366219}*/: this.hdz = null; this.hdx = null; String format = String.format("public_search_%s_key", 2); SharedPreferences.Editor edit = jaa.bH(OfficeApp.arx(), "search_keyword_file").edit(); for (int i = 0; i < 20; i++) { edit.putString(format + i, ""); } edit.commit(); this.hdu.setVisibility(8); return; default: return; } } public final void refreshView() { if (this.hdw == null || this.hdw.length <= 0) { this.gZT.setVisibility(8); } else { this.gZS.removeAllViews(); for (int i = 0; i < this.hdw.length; i++) { this.gZS.addView(ghe.a(this.mActivity, this.gZS, R.layout.phone_public_flow_recommend_item, this.hdw[i], "hotrecommend", this.haZ)); } this.gZT.setVisibility(0); } if (this.hdx == null || this.hdx.length <= 0) { this.hdu.setVisibility(8); return; } this.hdt.removeAllViews(); for (int i2 = 0; i2 < this.hdx.length; i2++) { this.hdt.addView(ghe.a(this.mActivity, this.hdt, R.layout.phone_public_flow_recommend_item, this.hdx[i2], "searchhistory", this.haZ)); } this.hdu.setVisibility(0); } }